package com.glasses.primework;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.primefaces.context.RequestContext;

@ManagedBean
@SessionScoped
public class RuntimeUpdatesBean {
    private String texta = "", textb = "";
    private boolean outcome;
    
    public String getTexta() {
        if (texta.length()%10 == 0)
            texta += "<br>";
        texta += "a";
        System.out.println("RuntimeUpdatesBean.getTexta() = " + texta);
        return texta;
    }
    
    public String getTextb() {
        if (textb.length()%10 == 0)
            textb += "<br>";
        textb += "b";
        System.out.println("RuntimeUpdatesBean.getTextb() = " + textb);
        return textb;
    }
    
    public void save() {
        RequestContext requestContext = RequestContext.getCurrentInstance();
        
        if(outcome) {
            System.out.println("RuntimeUpdatesBean.save() = update forma:panela");
            requestContext.update("forma:panela");
            outcome = false;
        } else {
            System.out.println("RuntimeUpdatesBean.save() = update forma:panelb");
            requestContext.update("forma:panelb");
            outcome = true;
        }
    }
}
